﻿
#region Usings

#endregion
namespace LongNet.Util.DataTypes
{
    /// <summary>
    /// Pairs two items together
    /// </summary>
    /// <typeparam name="T1">Type for the left hand side</typeparam>
    /// <typeparam name="T2">Type for the right hand side</typeparam>
    public class Pair<T1, T2>
    {
        #region Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        public Pair()
        {

        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Left">Left hand side of the pair</param>
        /// <param name="Right">Right hand side of the pair</param>
        public Pair(T1 Left, T2 Right)
        {
            this.Left = Left;
            this.Right = Right;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Left hand item
        /// </summary>
        public T1 Left { get; set; }

        /// <summary>
        /// Right hand item
        /// </summary>
        public T2 Right { get; set; }

        #endregion

        #region Public Overridden Properties

        public override int GetHashCode()
        {
            if (Left != null && Right != null)
            {
                return Left.GetHashCode() ^ Right.GetHashCode();
            }
            return 0;
        }

        public override bool Equals(object obj)
        {
            if (obj != null && obj is Pair<T1, T2>)
            {
                return Equals(Left, ((Pair<T1, T2>)obj).Left) && Equals(Right, ((Pair<T1, T2>)obj).Right);
            }
            return false;
        }

        #endregion
    }
}